package com.jk11a.shangdaast.library;
import com.jk11a.shangdaast.R;
import com.jk11a.shangdaast.subject.Subject;
import com.jk11a.shangdaast.user.*;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import android.widget.AdapterView.OnItemSelectedListener;
public class lib_read extends Activity {
	private static final String[] m={"一楼","二楼 ","三楼 ","四楼","五楼"};
	    private TextView view ;
	    private Spinner spinner;
	    private ArrayAdapter<String> adapter;
	@Override
	  public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.lib_read);
	        view = (TextView)findViewById(R.id.spinnerText);
	        spinner = (Spinner) findViewById(R.id.Spinner01);

	                adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,m);
	                adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	                //将adapter 添加到spinner中
	                spinner.setAdapter(adapter); 
	                //添加事件Spinner事件监听 
	                spinner.setOnItemSelectedListener(new SpinnerSelectedListener());
	                 
	                //设置默认值
	                spinner.setVisibility(View.VISIBLE);
	                 
	            }
	             
	            //使用数组形式操作
	            class SpinnerSelectedListener implements OnItemSelectedListener{

	                public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
	                        long arg3) {
	                    view.setText("你要查阅的楼层是："+m[arg2]);
	                }
	         
	                public void onNothingSelected(AdapterView<?> arg0) {
	                }
	            }
	      	  public void login(View v){
	      		  Intent intent =new Intent();   //退出app，跳转到登录首界面
	      		  intent.setClass(lib_read.this , LoginActivity.class);
	      		  startActivity(intent);
	      	  }


}
